https://leetcode.cn/problems/3sum/description/
15. 三数之和

class Solution {
public:
    vector<vector<int>> threeSum(vector<int>& nums) {
        vector<vector<int>> vv;
        sort(nums.begin(),nums.end());
        int keyi=0;
        for(int keyi=0;keyi<nums.size();)
        {
            if(nums[keyi]>0) break;
            int left=keyi+1,right=nums.size()-1;
            int target=-nums[keyi];
            //固定一个找俩数和==keyi
            while(left<right)
            {
                int sum=nums[left]+nums[right];
                if(sum>target)
                        --right;
                else if(sum<target)
                        ++left;
                else
                {
                    vv.push_back({-target,nums[left],nums[right]});
                    left++,right--;
                    while(left<right&&nums[right]==nums[right+1])
                        --right;
                    while(left<right&&nums[left]==nums[left-1])
                        ++left;
                }
            }
            ++keyi;
            while(keyi<nums.size()&&(nums[keyi]==nums[keyi-1])) ++keyi;
        }    
        return vv;
    }
};